package com.shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.pojo.pms.Pms_Attr;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

//属性mapper层
public interface Pms_Attr_Mapper extends BaseMapper<Pms_Attr> {

    //根据当前分类ID和分组ID来查询属性
    @Select("select * from pms_attr where attr_id in(select attr_id from pms_attr_attrgroup_relation where attr_group_id=#{attr_group_id} and catelog_id=#{catelog_id})")
    List<Pms_Attr> findAllAttrByCatelogIdAndGroupId(@Param("attr_group_id") Long attr_group_id, @Param("catelog_id") Long catelog_id);
     //查询当前分类下的全部销售属性
       @Select("select * from pms_attr where attr_id in(select attr_id from pms_category_attr where cat_id=#{catelog_id} and attr_type=0 or cat_id=#{catelog_id} and  attr_type=2)")
        List<Pms_Attr> findAllSaleAttr(Long catelog_id);
}
